package services.impl;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

import dao.UserDao;
import dao.impl.UserDaoImpl;
import entity.User;
import services.UserService;
import util.Base64Sec;
public class UserServiceImpl implements UserService{
	private UserDao userDao;

	public UserServiceImpl() {
		userDao = new UserDaoImpl();
	}

	@Override
	public void userRegister(String pwd,String nicheng,String qqcard) {
		
		String newPwd = Base64Sec.enCode(pwd);
		try {
			userDao.Register(qqcard, newPwd,nicheng);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	@Override
	public User userLogin(String qq, String pwd) {
		User user = null;
		
		String newPwd = Base64Sec.enCode(pwd);
		try {
			user = userDao.loginByNameAndPwd(qq, newPwd);

		} catch (SQLException e) {
			e.printStackTrace();
		}
		return user;
	}
}
